home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / noweb / src / lib / unmarkup < prev   
Text File  |  1995-02-24  |  1KB  |  40 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1991 by Norman Ramsey.  All rights reserved.
  4. # See file COPYRIGHT for more information.
  5.  
  6. nawk '
  7. /^@begin docs 0$/ { next }
  8. /^@begin docs / { printf "@ " }
  9. /^@begin code / { }
  10. /^@end [cd]o[dc][es] / { 
  11.         if (dangling_text) printf "\n"
  12.         dangling_text = 0
  13.                 printf "%s", deflines
  14.                 if (defline != "") printf "%s\n", defline
  15.                 deflines = "" ; defline = ""
  16.                }
  17. /^@defn / { printf "<<%s>>=", substr($0,7) }
  18. /^@text $/ {next}
  19. /^@text / { 
  20.   gsub("<<", "@<<");
  21.   gsub(">>", "@>>");
  22.   printf "%s", substr($0,7) 
  23.   dangling_text = 1
  24. }
  25. /^@quote$/    { printf("[["); dangling_text = 1 }
  26. /^@endquote$/ { printf("]]"); dangling_text = 1 }
  27. /^@nl$/       { printf "\n"; dangling_text = 0}
  28.  
  29. /^@index defn / {
  30.      if (defline == "") defline = "@ %def"
  31.      defline = defline " " substr($0, 13)
  32. }
  33. /^@index nl$/ {
  34.      deflines = deflines defline "\n"
  35.      defline = ""
  36. }
  37. /^@use / { printf "<<%s>>", substr($0,6)
  38.            dangling_text = 1
  39.          }' $* | sed 's/^@ $/@/'
  40.